<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
  <title>省略号代替超出文字</title>
  <style>
    * {
      padding: 0;
      margin: 0;
    }

    .box {
      width: 200px;
      height: 224px;
      padding: 10px;
      box-sizing: border-box;
      border: 1px solid #ebebeb;
      border-radius: 4px;
      position: absolute;
      top: 50px;
      left: 50px;
    }

    .pic {
      width: 180px;
      height: 180px;
      background-color: honeydew;
    }

    .title {
      margin-top: 10px;
      font-size: 14px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      -webkit-transition: all .3s ease-out;
      -moz-transition: all .3s ease-out;
      -o-transition: all .3s ease-out;
      -ms-transition: all .3s ease-out;
      transition: all .3s ease-out;
    }
  </style>
</head>

<body>
  <h3 style="margin-left: 50px;margin-top: 20px;">鼠标悬停文字，可显示隐藏文字</h3>
  <div class="box">
    <div class="pic"></div>
    <p class="title">
      <span class="text">明月几时有，把酒问青天，不知天上宫阙，今夕是何年</span>
    </p>
  </div>
  <div class="box" style="left:300px;">
    <div class="pic"></div>
    <p class="title">
      <span class="text">明月几时有，把酒问青天，不知天上宫阙，今夕是何年</span>
    </p>
  </div>
</body>
<script>
  $(function () {
    $('.title').hover(function () {
      var width = $(this).width();
      var width_b = $(this).find('.text').width();
      var index_px = width - width_b;
      if (width <= width_b) {
        $(this).css('text-indent', index_px);
      }
    }, function () {
      $(this).css('text-indent', 0);
    })
  })
</script>

</html>